package pattern.singleton;

import java.util.concurrent.atomic.AtomicReference;

/**
 * @author ytj
 * @date 2025/8/6
 */
public class Singleton4 {
    private Singleton4(){

    }

    private static final AtomicReference<Singleton4> singleton=new AtomicReference<>();

    public static final Singleton4 getSingletons(){
        if(singleton.get()==null){
            singleton.compareAndSet(null,new Singleton4());
        }
        return singleton.get();
    }
}
